import React from 'react'
import { AutoComplete } from 'antd';


export default class Complete extends React.Component {
  state = {
    value: '123',
    dataSource: [],
  };

  onSearch = searchText => {
    this.setState({
      dataSource: !searchText ? [] : [searchText, searchText.repeat(2), searchText.repeat(3)],
    });
  };

  onChange = value => {
    this.setState({ value });
  };

  render() {
    const { dataSource, value } = this.state;
    return (
      <div>
        <AutoComplete
          dataSource={dataSource}
          style={{ width: 200 }}
          onSelect={(value)=>  console.log('onSelect', value)}
          onSearch={this.onSearch}
          placeholder="在这里输入"
        />
        <br />
        <br />
        <AutoComplete
          value={value}
          dataSource={dataSource}
          style={{ width: 200 }}
          onSelect={(value)=>  console.log('onSelect', value)}
          onSearch={this.onSearch}
          onChange={this.onChange}
          placeholder="控制方式"
        />
      </div>
    );
  }
}